# -*-coding:utf-8-*-

import pymysql

filename = "ciku/贪腐词库.txt"

data = []
for line in open(filename, "r", encoding="utf-8"):  # 设置文件对象并读取每一行文件
    data.append(line.replace('\n', ''))             # 将每一行文件加入到list中

print(data)

db = pymysql.connect('182.92.226.32', 'root', 'kybus123456', 'theOld')
cursor = db.cursor()

sql = "INSERT INTO system_bannedWord(theme,content,createTime) VALUES(%s,%s,NOW())"
for dd in data:
    if dd is not None:
        cursor.execute(sql, ['贪腐词库', dd])

print("数据库导入操作")

db.commit()
db.close
